/**
 * Created by Administrator on 2017/7/12 0012.
 */
//接口中接入页面状态判断complete
/*
 清除多余数据
 */
$.cookie("eid","");//经验id
$.cookie("qid","");//问题ID
$.cookie("newsimg","");//新闻图片
$.cookie("newstitle","");//新闻标题
$.cookie("newstypeid","");//新闻类别
$.cookie("newsurl","");//新闻网址
$.cookie("thumbsUp","");//新闻点赞
$.cookie("newsShareId","");//新闻分享id
$.cookie("puluShowPage","");//资讯页面类别
$.cookie("delFriend","");//删除好友

/*
 判断是否在微信打开
 */

var sendid="";
if(!is_weixn()&&$.cookie("MYID")){
    sendid="?id="+$.cookie("MYID");
}

/*
 页面加载参数
 */
var ulid="#mainbody";
if($.cookie("MYID")){var id= $.cookie("MYID");}
var pageSize=10;//默认一页加载10条数据
var currentIndex=1;//页码
var readyover=0;

////广告
//var bannerDiv=[
//    //其他资源 0
//    "<div class='pagedlist_item' onclick='gotoOth()'>" +
//    "<div class='remindImgOth'><img src='img/remindImgOth.jpg'/></div><h1>有哪些其他的资源可以分享…<span class='rt'>点此发布</span></h1>"+
//    "</div>",
//    //经验 1
//    "<div class='pagedlist_item' onclick='gotoExp()'>" +
//    "<div class='remindImgExp1'><img src='img/remindImgExp1.jpg'/></div><h1>最近有什么电影推荐？<span class='rt'>点此发布</span></h1>"+
//    "</div>",
//    //单身资源 2
//    "<div class='pagedlist_item' onclick='gotoSin()'>" +
//    "<div class='remindImgSin'><img src='img/remindImgSin.jpg'/></div><h1>我也来分享身边的单身资源… <span class='rt'>点此发布</span></h1>"+
//    "</div>",
//    //经验 3
//    "<div class='pagedlist_item' onclick='gotoExp()'>" +
//    "<div class='remindImgExp2'><img src='img/remindImgExp2.jpg'/></div><h1>最近有什么好看的书？<span class='rt'>点此发布</span></h1>"+
//    "</div>",
//    //悬赏 4
//    "<div class='pagedlist_item' onclick='gotoQue()'>" +
//    "<div class='remindImgQue'><img src='img/remindImgQue.jpg'/></div><h1> 有什么烦恼解不开？<span class='rt'>点此发布</span></h1>"+
//    "</div>",
//    //产品 5
//    "<div class='pagedlist_item' onclick='gotoPro()'>" +
//    "<div class='remindImgPro'><img src='img/remindImgPro.jpg'/></div><h1>推广自己的产品项目…<span class='rt'>点此发布</span></h1>"+
//    "</div>",
//    //6 jy
//    "<div class='pagedlist_item' onclick='gotoExp()'>" +
//    "<div class='remindImgExp1'><img src='img/remindImgExp2.jpg'/></div><h1>有什么饭店推荐？<span class='rt'>点此发布</span></h1>"+
//    "</div>",
//    //7 jy
//    "<div class='pagedlist_item' onclick='gotoExp()'>" +
//    "<div class='remindImgExp2'><img src='img/remindImgExp2.jpg'/></div><h1>有什么适合游玩的地方？<span class='rt'>点此发布</span></h1>"+
//    "</div>",
//    //8 jy
//    "<div class='pagedlist_item' onclick='gotoExp()'>" +
//    "<div class='remindImgExp1'><img src='img/remindImgExp2.jpg'/></div><h1>最近有啥购物经验？<span class='rt'>点此发布</span></h1>"+
//    "</div>",
//    //9 jy
//    "<div class='pagedlist_item' onclick='gotoExp()'>" +
//    "<div class='remindImgExp2'><img src='img/remindImgExp2.jpg'/></div><h1>最近有什么推荐的工作午餐？<span class='rt'>点此发布</span></h1>"+
//    "</div>",
//    //10 jy
//    "<div class='pagedlist_item' onclick='gotoExp()'>" +
//    "<div class='remindImgExp1'><img src='img/remindImgExp2.jpg'/></div><h1>最近遇到什么吃亏事？<span class='rt'>点此发布</span></h1>"+
//    "</div>",
//    //11 jy
//    "<div class='pagedlist_item' onclick='gotoExp()'>" +
//    "<div class='remindImgExp1'><img src='img/remindImgExp2.jpg'/></div><h1>最近有什么划算事？<span class='rt'>点此发布</span></h1>"+
//    "</div>",
//    //12 jy
//    "<div class='pagedlist_item' onclick='gotoExp()'>" +
//    "<div class='remindImgExp1'><img src='img/remindImgExp2.jpg'/></div><h1>最近有什么新奇事？<span class='rt'>点此发布</span></h1>"+
//    "</div>",
//    //13 xs
//    "<div class='pagedlist_item' onclick='gotoQue()'>" +
//    "<div class='remindImgQue'><img src='img/remindImgQue.jpg'/></div><h1>有什么困惑想不通？<span class='rt'>点此发布</span></h1>"+
//    "</div>",
//    //14 xs
//    "<div class='pagedlist_item' onclick='gotoQue()'>" +
//    "<div class='remindImgQue'><img src='img/remindImgQue.jpg'/></div><h1>有什么好奇的事？<span class='rt'>点此发布</span></h1>"+
//    "</div>"
//]

if(!$.cookie("pulutype")){$.cookie("pulutype",1)};//第一次进入没有类型
if(!$.cookie("pululot")){$.cookie("pululot","")};//第一次进入
if(!$.cookie("pululat")){$.cookie("pululat","")};//第一次进入
/*
 页面加载类型 清除数据
 */
function clearPageCookie(){
    $.cookie("pulutype",1);//筛选类型 时间
    $.cookie("puluIndexType","");//切换类型
    $.cookie("puluscrollTop","");//定位
    $.cookie("pulucurrentIndex","");
    $.cookie("selectType","");//经验类别
    //
    $.cookie("changeQue","");
    $.cookie("eid","");
    $.cookie("fromuser","");
    $.cookie("pexpid","");
    $.cookie("pexpuid","");
    $.cookie("sharenewsid","");
    $.cookie("newsid","");
    $.cookie("searchType","");
};
if(/#clear/.test(location.href)){
    clearPageCookie();
}
else if($.cookie("puluIndexType")){
    $("#page_title .option").attr("class","option");
    switch($.cookie("puluIndexType")){
        case "0":
            $("#allType").attr("class","option active");
            $("#PuluTitleType").attr("class","allType");
            break;
        case "2":
            $("#queType").attr("class","option active");
            $("#PuluTitleType").attr("class","queType");
            break;
        case "3":
            $("#expType").attr("class","option active");
            $("#PuluTitleType").attr("class","expType");
            break;
        case "4":
            $("#resType").attr("class","option active");
            $("#PuluTitleType").attr("class","resType");
            break;
    }
}
/*
 页面跳转
 */
////联系人
//$("#gofirend").click(function(){
//    if($.cookie("MYID")){
//        location.href="chatpage.html";
//    }
//});
//订阅
$("#gosubsc").click(function(){
    if($.cookie("MYID")){
        location.href="subscribe.html";
    }
});
//我
$("#gomy").click(function(){
    if($.cookie("MYID")){
        $.cookie("setpageLastNoteType","");
        location.href="setpage.html";
    }
});
//同层
$(".goPuluLow").click(function(){
    if($.cookie("MYID")){
        $.cookie("puluIndexType","");
        clearPageCookie();
        location.href="puluLow.html";
    }
});
//上层
$(".goPuluUp").click(function(){
    if($.cookie("MYID")){
        $.cookie("puluIndexType","");
        clearPageCookie();
        location.href="pulu.html";
    }
});
/*
 * 高德地图
 */
function mapftn(){
    //没有坐标信息
    if(!$.cookie("pululot")||!/[0-9]/.test($.cookie("pululot"))){
        var map, geolocation;
        //加载地图，调用浏览器定位服务
        map = new AMap.Map('mapplace', {
            resizeEnable: true
        });
        map.plugin('AMap.Geolocation', function() {
            geolocation = new AMap.Geolocation({
                enableHighAccuracy: true,//是否使用高精度定位，默认:true
                noIpLocate:0,
                GeoLocationFirst:true,//默认为false，设置为true的时候可以调整PC端为优先使用浏览器定位，失败后使用IP定位
                convert: true,         //自动偏移坐标，偏移后的坐标为高德坐标，默认：true
                timeout: 15000          //超过15秒后停止定位，默认：无穷大
            });
            map.addControl(geolocation);
            geolocation.getCurrentPosition();
            AMap.event.addListener(geolocation, 'complete', onComplete);//返回定位信息
            AMap.event.addListener(geolocation, 'error', onError);      //返回定位出错信息
        });
        //解析定位结果
        function onComplete(data) {
            var expiresDate= new Date();
            expiresDate.setTime(expiresDate.getTime() + (60 * 60 * 1000));
            //有效60分钟
            $.cookie("pululot",data.position.lng,{expires : expiresDate});
            $.cookie("pululat",data.position.lat,{expires : expiresDate});
            getallnote(currentIndex,pageSize);
        }
        //解析定位错误信息
        function onError(data) {
            $("#nonews").css("display","block");
            $("#waiting1").css("display","none");
            $("#nonews1").css("display","none");
        }
    }
    //保存坐标信息
    else{
        getallnote(currentIndex,pageSize);
    }
}

/*
 * 保存跳转页码 距离
 */
function savepage(){
    var scrollTop=$(window).scrollTop();
    $.cookie("puluscrollTop",scrollTop);
    $.cookie("pulucurrentIndex",currentIndex);
}

/*
 消息通知
 */
if($.cookie("MYID")){
    if($.cookie("mynotic")=="loaded"){
        //新消息已经看过
        $.cookie("mynotic","");
    }else{
        $.ajax({
            type:"get",
            url:getanswernumurl+id,
            datatype:"json",
            success:function(d){
                if(d.Data>0){
                    $("#newnotenotice").css("display","block");
                    $("#newnotenotice").html(d.Data);
                }
            }
        });
    }

    ////申请通知
    //if($.cookie("comefrom")=="addnewfriends"){
    //    //来自新的好友页面
    //    //已经看过好友申请
    //    $.cookie("comefrom","");
    //}else{
    //    $.ajax({
    //        type:"get",
    //        url:getfriendnotenumurl+id,
    //        datatype:"json",
    //        success:function(d){
    //            if(d.Data>0){
    //                $.cookie("indexFriendNum",d.Data);//首页获取的好友申请个数
    //                //去过新的好友页面 并且保存的好友申请个数和获取的好友申请个数形同 认为已经看过
    //                if($.cookie("friendMsgNum")&&$.cookie("indexFriendNum")==$.cookie("friendMsgNum")&&$.cookie("changeFMN")!=="changed"){
    //                    //有好友的申请数量 并且没有处理好友申请 获取到的好友申请数和保存个数一样
    //                }else{
    //                    $.cookie("friendMsgNum","");
    //                    $.cookie("changeFMN","");
    //                    $("#gofirend i").css("display","block");
    //                }
    //            }
    //            else{
    //                $.cookie("friendMsgNum","");
    //                $.cookie("changeFMN","");
    //                $.cookie("indexFriendNum","0");//首页获取的好友申请个数
    //            }
    //        }
    //    });
    //}
    ////留言通知
    //if($.cookie("liuyan")=="read"){
    //    //留言已经看过
    //    $.cookie("liuyan","");
    //}else{
    //    $.ajax({
    //        type:"get",
    //        url:messagenotenumurl+id,
    //        datatype:"json",
    //        success:function(d){
    //            if(d.Data.msg=="有新留言"){
    //                $("#gofirend i").css("display","block");
    //            }
    //        }
    //    });
    //}
    //新闻更新
    if($.cookie("subscribe")=="loaded"){
        //资讯圈已经看过
        $.cookie("subscribe","");
    }else{
        $.ajax({
            type:"get",
            url:newsUploadUrl+id,
            datatype:"json",
            success:function(d){
                if(d.Message=="有更新"){
                    $("#gosubsc i").css("display","block");
                }
            }
        });
    }
}

/*
 搜索
 */
//$("#gotosearch").click(function(){
//    if($.cookie("MYID")){
//        readyover=0;
//        $.cookie("searchPageCurrentIndex","");//搜索定位
//        $.cookie("searchPageTop","");
//        $.cookie("searchType","");
//        location.href="searchdetail.html";
//    }
//});

/*
 点击三次加好友
 */
//$("#threeFriOk").click(function(){
//    var mynick="";
//    if($.cookie("MYNICK")){ mynick=$.cookie("MYNICK");}
//    conn.subscribe({
//        to: testUserId,
//        message: mynick+"已经阅读你的pulu3次，请求加为好友"
//    });
//    canclick3=true;
//    clickOnce=true;
//    //发送好友模板
//    $.ajax({
//        type:"post",
//        url:savefriendnoteurl0,
//        data:{"userId": $.cookie("MYID"),"friendId":testUserId,"msg":""},
//        success:function(d){
//            $.ajax({
//                type:"post",
//                url:closeClick3,
//                datatype:"json",
//                data:{"userId":$.cookie("MYID"),"quserId":testUserId},
//                success:function(data){
//                    $("#threeFriend").css("display","none");
//                    readyover=0;
//                    location.href=goClick3Url;
//                }
//            });
//        }
//    });
//});
//$("#threeFriNo").click(function(){
//    canclick3=true;
//    clickOnce=true;
//    $.ajax({
//        type:"post",
//        url:closeClick3,
//        datatype:"json",
//        data:{"userId":$.cookie("MYID"),"quserId":testUserId},
//        success:function(data){
//            $("#threeFriend").css("display","none");
//            readyover=0;
//            location.href=goClick3Url;
//        }
//    });
//});

/*
 不能发布 实名认证
 */
//关闭弹框
$("#canNotSend .closeBtn").click(function(){
    $("#canNotSend").css("display","none");
    $("html").css("overflow","auto");
});
//去认证
var goPageType="";
function goAuthenticate(){
    location.href="authenticate.html?goPage="+goPageType;
}

/*
 发经验问题
 */
//var closeTimeOut=false;
//$("#sendbtn").click(function(){
//    clearTimeout();
//    closeTimeOut=true;
//    $("#page_title .select").hide();
//    $("#typelist").hide();
//    $(".toparr").hide();
//    $("#sendbtn .select").toggle();
//    $("#showMore").css("display","block");
//    $("#sendbtn .select .listBox").css("display","none");
//});
function gotoExp(){
    savepage();
    if(is_weixn()){
        $.cookie("expkeyword","");
        $.cookie("expType","");
        $.cookie("sendque","");
        readyover=0;
        location.href="http://www.pulu.com/weixin/sendexpgpc.html";
    }
    else{
        readyover=0;
        location.href="https://www.pulu.com/weixin/sendexpgpc.html?id="+id;
    }
}
$("#goExp").click(function(){
    goPageType="goExp";
    if($.cookie("validateLevel")!=1&&$.cookie("validateLevel")!=2){
        $("#canNotSend").css("display","block");
    }else{
        gotoExp();
    }
});
function gotoQue(){
    savepage();
    if(is_weixn()){
        $.cookie("expkeyword","");
        $.cookie("expType","");
        $.cookie("sendque","question");
        readyover=0;
        location.href="http://www.pulu.com/weixin/sendexpgpc.html";
    }
    else{
        readyover=0;
        location.href="https://www.pulu.com/weixin/sendexpgpc.html?id="+id+"#sendque=question";
    }
}
$("#goQue").click(function(){
    goPageType="goQue";
    if($.cookie("validateLevel")!=1&&$.cookie("validateLevel")!=2){
        $("#canNotSend").css("display","block");
    }else{
        gotoQue();
    }
});

$("#choiceSendType").click(function(){
    $("#choiceSendType").css("display","none");
    $("body").attr("class","");
});
function gotoSin(){
    savepage();
    $.cookie("expkeyword","");
    $.cookie("expType","");
    $.cookie("sendque","");
    $("#choiceSendType").css("display","none");
    $("body").attr("class","");
    readyover=0;
    location.href="sendexpgpc.html?goSingle";
}
$("#goSingleQ").click(function(){
    gotoSin();
});
function gotoPro(){
    savepage();
    $("body").attr("class","");
    $.cookie("expkeyword","");
    $.cookie("expType","");
    $.cookie("sendque","");
    $("#choiceSendType").css("display","none");
    readyover=0;
    location.href="sendexpgpc.html?goProgect";
}
$("#goProgectQ").click(function(){
    gotoPro();
});
function gotoOth(){
    savepage();
    $("body").attr("class","");
    $.cookie("expkeyword","");
    $.cookie("expType","");
    $.cookie("sendque","");
    $("#choiceSendType").css("display","none");
    readyover=0;
    location.href="sendexpgpc.html?goOther";
}
$("#goOtherQ").click(function(){
    gotoOth();
});

/*
 切换发布类别
 */
$("#showMore").click(function(){
    clearTimeout();
    //取消事件冒泡
    var e=arguments.callee.caller.arguments[0]||event;
    if (e && e.stopPropagation) {
        e.stopPropagation();
    } else if (window.event) {
        window.event.cancelBubble = true;
    }
    $("#choiceSendType").css("display","block");
    $("body").attr("class","overflow");
    $("#sendbtn .select").slideUp(100);
});

/*
 经验加载方法
 */
//跳转方法
function gotopage(d){
    savepage();//保存页码 距离
    //清除转发者信息 防止返回信息保存
    $.cookie("shareUserId","");
    $.cookie("fromuser","");
    //canclick3=true;//点击三次判断
    //clickOnce=true;
    readyover=0;
    location.href=goClick3Url;
}
//判断点击三次
var goClick3Url="";
//var testUserId="";
//var canclick3=true;//点击三次判断
//var clickOnce=true;
function hrefgo(d){
    //if(clickOnce){
        //冒泡
        var eve=arguments.callee.caller.arguments[0]||event;
        if (eve && eve.stopPropagation) {
            eve.stopPropagation();
        } else if (window.event) {
            window.event.cancelBubble = true;
        }
        var shareuserid="";
        var url= d.dataset.href;
        if(d.dataset.shareuserid){
            $.cookie("shareUserId",d.dataset.shareuserid);
            if(!is_weixn()){shareuserid="#shareUserId="+d.dataset.shareuserid;}
        }
        goClick3Url=url+shareuserid;

        /**/
        gotopage();
        //if(d.dataset.nick){
        //    $("#threeFriendNick").html(d.dataset.nick);
        //}else{
        //    $("#threeFriendNick").html("TA");
        //}
        ////三次加好友
        ////shareuserid>euser
        //testUserId=d.dataset.euser;
        //if(d.dataset.shareuserid){testUserId=d.dataset.shareuserid};
        //if(testUserId!= $.cookie("MYID")&&canclick3){
        //    canclick3=false;
        //    clickOnce=false;
        //    $.ajax({
        //        type:"get",
        //        url:click3addFriend+"?userId="+$.cookie("MYID")+"&quserId="+testUserId,
        //        datatype:"json",
        //        success:function(data){
        //            canclick3=true;
        //            clickOnce=true;
        //            if(data.Data){$("#threeFriend").css("display","block");}
        //            else{gotopage(d);}
        //        },
        //        error:function(){
        //            canclick3=true;
        //            clickOnce=true;
        //        }
        //    })
        //}
        //else{gotopage(d)}
    //}
}

/*
 关键词列表页
 */
//
function gotoheiexp(data){

}
//跳转经验类别
function goexptype(d){
    //取消事件冒泡
    var e=arguments.callee.caller.arguments[0]||event;
    if (e && e.stopPropagation) {
        e.stopPropagation();
    } else if (window.event) {
        window.event.cancelBubble = true;
    }
    savepage();//保存页码 距离
    readyover=0;
    if(/^[0-9]+$/.test(d.dataset.type)){
        switch(parseInt(d.dataset.type)){
            case 1:$.cookie("selectType","");location.href="questionlistjy.html?type=1";break;//吃亏
            case 2:$.cookie("selectType","");location.href="questionlistjy.html?type=2";break;//划算
            case 3:$.cookie("selectType","");location.href="questionlistjy.html?type=3";break;//新奇
            case 4:$.cookie("selectType","");location.href="questionlistjy.html?type=4";break;//其他
            case 5:$.cookie("selectType","");location.href="questionlistjy.html?type=5";break;//电影
            case 6:$.cookie("selectType","");location.href="questionlistjy.html?type=6";break;//美食
            case 7:$.cookie("selectType","");location.href="questionlistjy.html?type=7";break;//旅游
            case 8:$.cookie("selectType","");location.href="questionlistjy.html?type=8";break;//读书
            case 22:
                $.cookie("selectType","");
                if(!is_weixn){location.href="questionlistjy.html?type=22&id="+$.cookie("MYID")}
                else{location.href="questionlistjy.html?type=22"};
                break;//附近
            case 23:$.cookie("selectType","");location.href="questionlistjy.html?type=23";break;//人生
            case 24:$.cookie("selectType","");location.href="questionlistjy.html?type=24";break;//育儿
            case 25:$.cookie("selectType","");location.href="questionlistjy.html?type=25";break;//工作
            case 26:$.cookie("selectType","");location.href="questionlistjy.html?type=26";break;//健康
            case 27:$.cookie("selectType","");location.href="questionlistjy.html?type=27";break;//购物
        }
    }else if(/^[a-z]+$/.test(d.dataset.type)){
        $.cookie("selectType","");
        readyover=0;
        location.href="questionlistjy.html?type="+d.dataset.type;
    }
}

var pageLevelType="高层";
if(/puluLow.html/.test(location.href)){pageLevelType="同层";}
//经验 资源
function jy(d){
    //全部经验页 返回家在重复使用jyhaveajax进行判断 pulupagejy.js
    if(d.title&& d.title.length>0){
        //匿名
        var unick="";
        if(d.questionUserNick){
            if(d.ishidename==1){unick="<a>匿名</a>";}
            else{unick="<a onclick='usergohref(this)' data-uid='"+d.questionUserId+"'>"+d.nick+"</a>";}
        }
        //头像
        var uimgword="";
        if(d.questionUserAva){
            if(d.ishidename==1){
                uimgword="<a href='javascript: ;'><img class='profile_photo_img' src='../img/af8.png' onload='showloadimg(this)'></a>";
            }else{
                uimgword="<a onclick='usergohref(this)' data-uid='"+d.questionUserId+"'><img class='profile_photo_img' src='http://42.62.66.198:8003/"+d.questionUserAva+"' onload='showloadimg(this)' style='display:none;'></a>";
            }
        }else{
            if(d.ishidename==1){
                uimgword="<a href='javascript: ;'><img class='profile_photo_img' src='../img/af8.png' onload='showloadimg(this)' style='display:none;'></a>";
            }else{
                uimgword="<a onclick='usergohref(this)' data-uid='"+d.questionUserId+"'><img onclick='gohrefftn(this)' class='profile_photo_img' src='../img/af8.png' onload='showloadimg(this)' style='display:none;'></a>";
            }
        };
        var otherid=d.userId;
        //时间
        var tim="";
        if(d.shareTime){tim=getDateDiff(getDateTimeStamp(d.shareTime));}
        //有没有图片
        var haveimg="";
        if(d.qImgs){haveimg="<span class='isheighlogo haveimg'></span>"}
        //是不是推荐
        var tuijianword="";
        var realName=""; //真名
        if(d.realName){realName=" ("+d.realName+")"};
        var moneysty='';
        if(d.isstanger===1){
            //tuijianword="系统推荐 ";
            realName="";
        }
        //钱
        var score="免费";
        var singlelogo="";
        var oriword="的经验";
        var sendPlacehold="经验";
        if(d.score>0){score="¥"+parseFloat(d.score)/100;}
        money="<span class='havemy jy' "+moneysty+"><i></i></span>";

        //是不是转换
        var isconvert="";
        if(d.iscovert&&d.iscovert===1){
            //isconvert="(悬赏完成转经验)"
        }
        //我也说说-->去关键词列表页
        var gotoheiexp="<div class='gotoheiexp' onclick='gotoheiexp(this)' data-qtype='"+d.qtype+"' data-keyword="+d.qid+">"+oriword+"</div>";
        //高额
        var isheilogo="";
        if(d.isHighExp===1||d.isHighExp===2){
            isheilogo="<span class='isheighlogo'></span>";
        }
        //经验类型
        var exptypeword="";
        if(d.qtype==3){
            if(d.expTypeInfo&&d.expTypeInfo.length>0){
                switch(d.expTypeInfo[0].id){
                    case 1:sendPlacehold="吃亏经验";break;//吃亏
                    case 2:sendPlacehold="划算经验";break;//划算
                    case 3:sendPlacehold="新奇体验";break;//新奇
                    case 4:sendPlacehold="其他经验";break;//其他
                    case 5:sendPlacehold="电影推荐";break;//电影
                    case 6:sendPlacehold="美食推荐";break;//美食
                    case 7:sendPlacehold="旅行经验";break;//旅游
                    case 8:sendPlacehold="读书经验";break;//读书
                    case 22:sendPlacehold="附近经验";break;//附近
                    case 23:sendPlacehold="人生体验";break;//人生
                    case 24:sendPlacehold="育儿经验";break;//育儿
                    case 25:sendPlacehold="工作经验";break;//工作
                    case 26:sendPlacehold="健康经验..";break;//健康
                    case 27:sendPlacehold="购物经验";break;//健康

                }
                for(var i=0;i<d.expTypeInfo.length;i++){
                    exptypeword+='<span class="exptype" onclick="goexptype(this)" data-type="'+d.expTypeInfo[i].id+'">'+d.expTypeInfo[i].name+'</span>  ';
                }
            }
        }
        //else{
        //    if(d.qtype==4){
        //        exptypeword='<span class="exptype" onclick="goexptype(this)" data-type="single">单身资源</span>';
        //    }else if(d.qtype==6){
        //        exptypeword='<span class="exptype" onclick="goexptype(this)" data-type="work">工作介绍</span>';
        //    }else if(d.qtype==7){
        //        exptypeword='<span class="exptype" onclick="goexptype(this)" data-type="house">租房买房</span>';
        //    }else if(d.qtype==8){
        //        exptypeword='<span class="exptype" onclick="goexptype(this)" data-type="progect">项目资源</span>';
        //    }else if(d.qtype==9){
        //        exptypeword='<span class="exptype" onclick="goexptype(this)" data-type="resource">人脉资源</span>';
        //    }else if(d.qtype==10){
        //        exptypeword='<span class="exptype" onclick="goexptype(this)" data-type="other">其他资源</span>';
        //    }
        //}

        //标题
        //var tit=codetoface(d.title)+"(还有"+d.wordcount+"字)";
        var tit=codetoface(d.title);
        var count=0;
        if(d.count){count=d.count;}
        //昵称
        var unick="";
        var datanick="";
        if(d.ishidename===1){
            unick="<a>"+tuijianword+"匿名</a>";
            datanick="匿名";
        }else{
            unick="<a onclick='usergohref(this)' data-uid='"+d.questionUserId+"'>"+tuijianword+"<i class='usernick'> "+d.questionUserNick+realName+"</i></a>";
            datanick=d.questionUserNick;
        }
        //位置
        var location="";
        if(d.pululocation){
            location="<div style='position:relative;'><p class='locationLogo' style='height:12px;position: absolute;bottom:2px;left:0;'></p><span style='color:#999;padding-left:15px;font-size:12px;'>"+d.pululocation+"</span></div>"
        }
        //关键词
        var keywordnor;
        var keyword="<span class='keywordtit'>查看更多有关</span>";
        if(d.keywords){
            keywordnor=d.keywords.split(",");
            for(var a=0;a<keywordnor.length;a++){
                keyword+="<span>"+keywordnor[a]+"</span>";
            }
        }
        var des="";
        //不是转发
        var shareTitle="";
        if(!d.shareUserId){
            if(!tim){tim="刚刚";}
        }
        //转发
        else if(d.shareUserId&&d.shareUserId.length>0){
            if(d.des){des=codetoface(d.des);}
            var count=0;
            if(d.count){count=d.count;}
            var sharetim=getDateDiff(getDateTimeStamp(d.shareTime.match(/[0-9\-T\:]+/)[0]));
            var shareName="";if(d.shareRealName){shareName=" ("+d.shareRealName+")"};
            unick="<a onclick='usergohref(this)' data-uid='"+d.shareUserId+"'><i class='usernick'>"+d.shareUserNick+shareName+"</i> 的转发</a>";
            if(d.isShowToMe!==1){
                if(d.shareUserId==id){pageLevelType="自己";}
                shareTitle='<div class="shareTitle"> <a onclick="usergohref(this)" data-uid="'+d.shareUserId+'">来自'+pageLevelType+'</a> <span>转发</span> </div>';
            }

            if(d.shareUserAva){
                uimgword="<a onclick='usergohref(this)' data-uid='"+d.shareUserId+"'><img class='profile_photo_img' src='http://42.62.66.198:8003/"+d.shareUserAva+"' onload='showloadimg(this)' style='display:none;'></a>";
            }else{
                uimgword="<a onclick='usergohref(this)' data-uid='"+d.shareUserId+"'><img onclick='gohrefftn(this)' class='profile_photo_img' src='../img/af8.png' onload='showloadimg(this)' style='display:none;'></a>";
            };
            var location="";
            if(d.pululocation){
                location="<div style='position:relative;margin-bottom:6px;'><img src='img/dingwei.png' style='height:12px;position: absolute;bottom:2px;left:0;'/><span style='color:#999;padding-left:15px;font-size:12px;'>"+d.pululocation+"</span></div>"
            }
            //转发调整金额样式
            var moneysty='';
            //money="<span class='havemy jy"+singlelogo+"' "+moneysty+"><i></i>"+score+"</span>";
            if(!sharetim){sharetim="刚刚";}
            tim=sharetim;
        };
        //var addplace="<div class='quick' style='display: block; font-size: 16px;'><div><div style='text-align: center;'><div>我也<br>说说</div></div></div><div>我也有"+sendPlacehold+"</div></div>";
        if(d.pululocation){
            location="<p style='position:relative;margin-bottom:4px;margin-top:8px;'><p class='locationLogo' style='position: absolute;bottom:11px;left:0;'></p><span style='color:#999;padding-left:15px;font-size:13px;'>"+d.pululocation+"</span></div>"
        };
        var newKeyWord="<i class='newKeyWord' onclick='gotoheiexp(this)' data-qtype='"+ d.qtype+"' data-keyword='"+d.qid+"'>"+d.keywords.split(",").join("|")+"|    </i>";
        //if(d.isredbag===1){score="红包";payNum=""}else{
        //    payNum="&nbsp;&nbsp;&nbsp;&nbsp;<span class='payNum'></span>"+payNum;
        //}
        var displayNone='style="display:none;"';
        if(d.isShowToMe===1){displayNone=""};
        $("#mainbody .addlistplace").append(
            "<div class='pagedlist_item shareexperience' onclick='hrefgo(this)' data-nick='"+datanick+"' data-euser='"+d.questionUserId+"' data-href='shareexppage.html?eid="+d.qid+"#fromuser="+id+"' data-shareuserid='"+d.shareUserId+"'>" +
                "<div class='feed_item feed_type_question'>" +
                    "<div class='borderbox'>"+
                        "<div class='ContentHeader' "+displayNone+">" +
                            "<div class='photo_info_layout size_small'>" +
                                "<div class='photo_wrapper'>" +
                                    "<div class='photo'>"+uimgword+"</div>" +
                                "</div>" +
                                "<div class='info_wrapper'>" +
                                    "<span class='user'>"+unick+"</span>"+
                                    //money+
                                    "<div class='ContentFooter' style='display:block;'>" +
                                        unick+"花费"+parseFloat(d.showMoney/100)+"显示给我看"+
                                    "</div>" +
                                "</div>" +
                            "</div>" +
                        "</div>"+

                        "<div class='info_wrapper' style='margin-bottom:7px;'> " +
                            shareTitle+
                            "<div class='info'> <span class='feed_item_answer_user'>"+des+"</span> </div> " +
                        "</div> " +
                        "<h1>"+
                            money+
                            "<a class='question_link'>"+
            newKeyWord+"<span>"+isconvert+tit+"("+d.WordCount+"字)"+haveimg+isheilogo+"</span>"+

            "</a>" +
                        "</h1>" +
                        "<div class='ActionBar Question'>" +
                            "<div class='action_bar_inner'>" +
                                "<div class='action_item'> " +
                                    "<a class='ReadMoreActionItem'>" +
                                        "<span class='scoreNum'>"+score+"</span>"+
                                        "<span class='browseNum'></span>"+
                                        count+
                                        //payNum+"&nbsp;&nbsp;&nbsp;&nbsp;" +
                                        "<span class='sendNum'></span>"+
                                        d.webchatCount+
                                    "</a>" +
                                    "<a class='rt'>"+tim+"</a>" +
                                "</div>" +
                            "</div>"+
                            location+
                        "</div>"+
                    "</div>" +
                "</div>" +
            "</div>"
        )
    };
};

/*
 问题加载方法
 */
//拿问题数据
function que(d){
    if(d.title&&d.title.length>0){
        //匿名
        var unick="";
        if(d.questionUserNick){
            if(d.ishidename==1){
                unick="<a>匿名</a>";
            }else{
                unick="<a onclick='usergohref(this)' data-uid='"+d.questionUserId+"'>"+d.nick+"</a>";
            }
        }
        //头像
        var uimgword="";
        if(d.questionUserAva&&d.ishidename!=1){
            if(d.ishidename==1){
                uimgword="<a><img onclick='gohrefftn(this)' class='profile_photo_img' src='../img/af8.png' onload='showloadimg(this)' style='display:none;'></a>";
            }else{
                uimgword="<a onclick='usergohref(this)' data-uid='"+d.questionUserId+"'><img class='profile_photo_img' src='http://42.62.66.198:8003/"+d.questionUserAva+"' onload='showloadimg(this)' style='display:none;'></a>";
            }
        }else{
            if(d.ishidename==1){
                uimgword="<a><img class='profile_photo_img' src='../img/af8.png' onload='showloadimg(this)' style='display:none;'></a>";
            }else{
                uimgword="<a onclick='usergohref(this)' data-uid='"+d.questionUserId+"'><img onclick='gohrefftn(this)' class='profile_photo_img' src='../img/af8.png' onload='showloadimg(this)' style='display:none;'></a>";
            }
        };
        //有没有图片
        var haveimg="";
        var showimgul="";
        var money="";//有没有钱 悬赏
        money="<span class='havemy xs'><b></b></span>";
        if(d.score>0){
            var score= parseFloat(d.score)/100;
            //money="<span class='havemy xs'><b></b>¥ "+score+"</span>";
        }
        var tim="";
        if(d.shareTime){tim=getDateDiff(getDateTimeStamp(d.shareTime));}
        var count=0;
        if(d.count){count=d.count;}
        //结帖
        var answerword="";
        var overword="";
        //if(d.status.toString()=="0"){
        //    overword="(已结帖)";
        //    money="<span class='havemy xs'><b></b> ¥ "+score+"已分配</span>";
        //}
        //问题转经验  回答数 付费数
        var tohrefurl="questiondetail.html?qid="+d.qid+"#fromuser="+id;
        var tranword="";
        var payoransw="回答 "+d.answerCount;
        if(d.ExpId&&d.ExpId!=0){
            tohrefurl="shareexppage.html?eid="+d.ExpId+"#fromuser="+id;
            tranword="(悬赏完成转经验)";
            overword="";//结帖清除
            payoransw="付费 "+d.payCount;
            //money="<span class='havemy xs'><b></b>¥ "+score+"</span>";
            money="<span class='havemy xs'><b></b></span>";
        }
        //昵称
        var unick="";
        var datanick="";
        var realName="";
        if(d.realName){realName=" ("+d.realName+")"};
        if(d.questionUserNick){
            //是不是推荐
            var tuijianword="";
            var moneysty="";
            if(d.isstanger===1){
                if(d.ishidename===1){unick="<a>系统推荐 匿名</a>";datanick="匿名";}
                //else{unick="<a onclick='usergohref(this)' data-uid='"+d.questionUserId+"'>系统推荐 <i class='usernick'>"+d.questionUserNick+"</i></a>";datanick=d.questionUserNick;}
                else{unick="<a onclick='usergohref(this)' data-uid='"+d.questionUserId+"'> <i class='usernick'>"+d.questionUserNick+"</i></a>";datanick=d.questionUserNick;}
            }
            else{
                if(d.ishidename===1){unick="<a>匿名</a>";datanick="匿名"}
                else{
                    unick="<a onclick='usergohref(this)' data-uid='"+d.questionUserId+"'><i class='usernick'>"+d.questionUserNick+realName+"</i></a>";datanick=d.questionUserNick;
                }
            }
        }
        //地址
        var location="";
        //关键词
        var keywordnor;
        var keyword="<span class='keywordtit'>查看更多有关</span>";
        if(d.keywords){
            keywordnor=d.keywords.split(",");
            for(var a=0;a<keywordnor.length;a++){
                keyword+="<span>"+keywordnor[a]+"</span>";
            }
        }
        //我也说说
        var gotoheiexp="<div class='gotoheiexp' onclick='gotoheiexp(this)' data-qtype='2' data-keyword="+d.qid+">的悬赏</div>";
        var tit=codetoface(d.title);
        var des="";
        var shareTitle="";
        if(!d.shareUserId){if(!tim||/[a-z]/.test(tim)){tim="刚刚";}}
        else if(d.shareUserId&&d.shareUserId.length>0){
            realName="";
            if(d.shareRealName){realName=" ("+d.shareRealName+")"};
            unick="<a onclick='usergohref(this)' data-uid='"+d.shareUserId+"'><i class='usernick'>"+d.shareUserNick+realName+"</i> 的转发</a>";
            if(d.shareUserAva){
                uimgword="<a onclick='usergohref(this)' data-uid='"+d.shareUserId+"'><img class='profile_photo_img' src='http://42.62.66.198:8003/"+d.shareUserAva+"' onload='showloadimg(this)' style='display:none;'></a>";
            }else{
                uimgword="<a onclick='usergohref(this)' data-uid='"+d.shareUserId+"'><img onclick='gohrefftn(this)' class='profile_photo_img' src='../img/af8.png' onload='showloadimg(this)' style='display:none;'></a>";
            };
            if(d.des){des=codetoface(d.des);}
            var sharetim="";
            if(d.shareTime){sharetim=getDateDiff(getDateTimeStamp(d.shareTime));}
            //转发调整金额样式
            //if(d.status.toString()=="0"){
            //    overword="(已结帖)";
            //    money="<span class='havemy xs' "+moneysty+"><b></b>¥"+score+"已分配</span>";
            //}
            //else{money="<span class='havemy xs' "+moneysty+"><b></b>¥"+score+"</span>";}
            money="<span class='havemy xs' "+moneysty+"><b></b></span>";
            if(!sharetim||/[a-z]/.test(sharetim)){sharetim="刚刚"};

            if(d.isShowToMe!==1){
                if(d.shareUserId==id){pageLevelType="自己";}
                shareTitle='<div class="shareTitle"> <a onclick="usergohref(this)" data-uid="'+d.shareUserId+'">来自'+pageLevelType+'</a> <span>转发</span> </div>';
            }
        }
        if(!tim){tim="刚刚"}
        //var addplace="<div class='quick' style='display: block; font-size: 16px;'><div><div style='text-align: center;'><div>我也<br>说说</div></div></div><div>我也有悬赏</div></div>";
        if(d.pululocation){
            location="<div style='position:relative;margin-bottom:4px;margin-top:8px;'><p class='locationLogo' style='position: absolute;bottom:3px;left:0;'></p><span style='color:#999;padding-left:15px;font-size:13px;'>"+d.pululocation+"</span></div>"
        };
        if(d.qImgs){
            showimgul="";
            haveimg="<span class='isheighlogo haveimg'></span>";
            for(var i=0;i< d.qImgs.length;i++){
                showimgul+='<li class="showimgli" style="background:url('+imgurl+d.qImgs[i]+')no-repeat center;background-size:cover;">'+
                '</li>'
            }
            showimgul='<ul class="showimgul" style="overflow: hidden;width: 15.5rem;margin-top: .125rem;">'+
            showimgul+
            '</ul>';
        };
        var newKeyWord="<i class='newKeyWord' onclick='gotoheiexp(this)' data-qtype='2' data-keyword='"+d.qid+"'>"+d.keywords.split(",").join("|")+"|    </i>";
        var displayNone='style="display:none;"';
        if(d.isShowToMe===1){displayNone=""};
        $("#mainbody .addlistplace").append(
            "<div class='pagedlist_item' onclick='hrefgo(this)' data-nick='"+datanick+"' data-shareuserid='"+d.shareUserId+"' data-euser='"+ d.questionUserId+"' data-href='"+tohrefurl+"'>" +
                "<div class='feed_item feed_type_question'>" +
                    "<div class='borderbox' data-shareuserid='"+d.shareUserId+"' data-page='#mainbody' data-href='questiondetail.html?qid="+d.qid+"#fromuser="+id+"'>"+
                        "<div class='ContentHeader' "+displayNone+">" +
                            "<div class='photo_info_layout size_small'>" +
                                "<div class='photo_wrapper'>" +
                                    "<div class='photo'>"+uimgword+"</div>" +
                                "</div>" +
                                "<div class='info_wrapper'>" +
                                    "<span class='user'>"+unick+"</span>"+
                                    //money+
                                    "<div class='ContentFooter' style='display:block;'>" +
                                         unick+"花费"+parseFloat(d.showMoney/100)+"显示给我看"+
                                    "</div>" +
                                "</div>" +
                            "</div>" +
                        "</div>"+

                        "<div class='info_wrapper' style='margin-bottom:7px;'> " +
                            shareTitle+
                            "<div class='info'> <span class='feed_item_answer_user'>"+des+"</span></div> " +
                        "</div> " +
                        "<h1>"+
                            money+
                            "<a class='question_link' onclick='hrefgo(this)' data-nick='"+datanick+"' data-shareuserid='"+d.shareUserId+"' data-euser='"+ d.questionUserId+"' data-href='"+tohrefurl+"'>"+
                                newKeyWord+"<span>"+overword+tranword+tit+"</span>"+
                            "</a>" +
                        "</h1>"+
                        showimgul+
                        "<div class='ActionBar Question'>"+
                            "<div class='action_bar_inner'>" +
                                "<div class='action_item'> " +
                                    "<a class='ReadMoreActionItem'>" +
                                        "<span class='scoreNum'>¥"+score+"</span>"+
                                        "<span class='browseNum'></span>"+
                                        count+
                                        //"<span class='answerNum'></span>"+
                                        //d.answerCount+"&nbsp;&nbsp;&nbsp;&nbsp;" +
                                        "<span class='sendNum'></span>"+
                                        d.webchatCount+
                                    "</a>" +
                                    "<a class='rt'>"+tim+"</a>" +
                                "</div>" +
                            "</div>"+
                            location+
                        "</div>" +
                    "</div>" +
                "</div>" +
            "</div>"
        );
    };
};

/*
 所有方法
 */
//获取所有数据
function getallnote(loadIndex,loadSize){
    readyover=1;
    if($.cookie("pululot")&&$.cookie("pulutype")==3){
        var urllot="&lot="+$.cookie("pululot");
        var urllat="&lat="+$.cookie("pululat");
    }else{
        var urllot="";
        var urllat="";
    }
    var sendtype=$.cookie("pulutype");
    var urlCode=puluindexlisturl_new;//默认为0
    if($.cookie("puluIndexType")==2){urlCode=puluAllQueUrl}
    else if($.cookie("puluIndexType")==3){urlCode=puluAllExpUrl}
    else if($.cookie("puluIndexType")==4){urlCode=getFtoT}//4到10
    var rankType=3;
    if(/puluLow.html/.test(location.href)){
        rankType=2;
    }
    if(!sendtype){sendtype=1};
    $.ajax({
        type:"get",
        url:urlCode+ $.cookie("MYID")+"&currentIndex="+loadIndex+"&pageSize="+loadSize+"&type="+sendtype+urllot+urllat+"&rankType="+rankType,
        complete:function(XHR, TS){
            if(XHR.status==0){
                window.location.reload();
            }
        },
        success:function(d){
            readyover=0;
            if(d.Message=="没有数据"||!d.Data||d.Data.length==0){
                $("#waiting1").css("display","none");
                $("#nonews1").css("display","block");
                $("#nonews").css("display","none");
            }
            else{
                $("#nonews").css("display","none");
                for(var i=0;i< d.Data.length;i++){
                    //新闻
                    if(d.Data[i].qtype===1){news(d.Data[i]);}
                    //问题
                    else if(d.Data[i].qtype===2){que(d.Data[i]);}
                    //经验//单身资源
                    else{jy(d.Data[i])}
                    ////每10条插入广告
                    //if(loadSize<=10){ //
                    //    //页面插入广告
                    //    if((i+1)%5==0){
                    //        var Rand = Math.random();
                    //        var num = 0 + Math.round(Rand * 15); //四舍五入
                    //        $("#mainbody .addlistplace").append(bannerDiv[num]);
                    //    }
                    //}else{
                    //    var loadPageNum=loadSize/10;//加载多少页
                    //    //判断10个
                    //    if((i+1)%5==0){
                    //        //页面插入广告
                    //        var Rand = Math.random();
                    //        var num = 0 + Math.round(Rand * 15); //四舍五入
                    //        $("#mainbody .addlistplace").append(bannerDiv[num]);
                    //    }
                    //}
                }
                if(d.Data.length<loadSize){
                    $("#waiting1").css("display","none");
                    $("#nonews1").css("display","block");
                    $("#nonews").css("display","none");
                }
                //页面定位
                if($.cookie("pulucurrentIndex")&&/[0-9]/.test($.cookie("pulucurrentIndex"))){
                    if(/^[0-9]+$/.test($.cookie("puluscrollTop"))){
                        var toTop= parseInt($.cookie("puluscrollTop"));
                        $(window).scrollTop(toTop);
                        //还原参数
                        pageSize=10;
                        currentIndex=parseInt($.cookie("pulucurrentIndex"));
                        //清除参数
                        $.cookie("puluscrollTop","");
                        $.cookie("pulucurrentIndex","");
                    }
                }
            }
        }
    })
}

function loadpage(){
    if($.cookie("pulutype")){
        $("#typelist li").attr("class","typelist");
        switch($.cookie("pulutype")){
            case "1":
                $("#labeltypename i").attr("class","sjType");
                $("#sjType").attr("class","typelist active");
                break;
            case "3":
                $("#labeltypename i").attr("class","fjType");
                $("#fjType").attr("class","typelist active");
                break;
            case "2":
                $("#labeltypename i").attr("class","llType");
                $("#llType").attr("class","typelist active");
                break;
            case "4":
                $("#labeltypename i").attr("class","zfType");
                $("#zfType").attr("class","typelist active");
                break;
        }
    }

    if($.cookie("pulucurrentIndex")&&/[0-9]/.test($.cookie("pulucurrentIndex"))){
        $("#mainbody div.addlistplace div").remove();//清空页面
        if(/^[0-9]+$/.test($.cookie("puluscrollTop"))){
            pageSize=parseFloat($.cookie("pulucurrentIndex"))*pageSize;
            currentIndex=1;//一页加载全部
        }else{
            pageSize=10;
            currentIndex=1;
        }
        getallnote(currentIndex,pageSize);
    }
    else{
        id=$.cookie("MYID");
        getallnote(currentIndex,pageSize);
    }
};

$(window).scroll(function(){
    $("#page_title .select").hide();

    $("#typelist").hide();
    $(".toparr").hide();

    $(".quicklist").css("display","none");
    $("#refreshbtn").css("display","block");
    var mainheight=$("#page_wrapper").height();
    var windowheight=$(window).height();
    var chajuli=$(window).scrollTop()-$("#page_wrapper").offset().top;
    var lastheight=mainheight-50;//极限距离
    //console.log($(window).scrollTop());
    if((chajuli+windowheight)>lastheight&&readyover===0){
        ++currentIndex;
        readyover=1;
        getallnote(currentIndex,10);
    }
});
///*
// 切换类别
// */
//$("#page_title>div").click(function(){
//    $("#page_title .select").toggle();
//    $("#typelist").hide();
//    $(".toparr").hide();
//    $("#sendbtn .select").hide();
//});
//$("#page_title .option").click(function(i){
//    //取消冒泡
//    var e=arguments.callee.caller.arguments[0]||event;
//    if (e && e.stopPropagation) {
//        e.stopPropagation();
//    } else if (window.event) {
//        window.event.cancelBubble = true;
//    }
//    //加载完成才可以切换
//    if(readyover==0){
//        var thisid=i.target.id.match(/[a-zA-Z]+/)[0];
//        $("#page_title .option").attr("class","option");
//        $("#"+thisid).attr("class","option active");
//        $(".select").hide();
//        ////数据还原
//        $("#waiting1").css("display","block");
//        $("#nonews1").css("display","none");
//        $("#nonews").css("display","none");
//        pageSize=10;
//        currentIndex=1;
//        //页面重新加载
//        $(window).scrollTop(0);
//        $("#mainbody div.addlistplace div").remove();//清空页面
//        if(thisid=="allType"){
//            $.cookie("puluIndexType",0);
//            $("#PuluTitleType").attr("class","allType");
//            getallnote(currentIndex,pageSize);
//        }
//        else if(thisid=="queType"){
//            $.cookie("puluIndexType",2);
//            $("#PuluTitleType").attr("class","queType");
//            getallnote(currentIndex,pageSize);
//        }
//        else if(thisid=="expType"){
//            $.cookie("puluIndexType",3);
//            $("#PuluTitleType").attr("class","expType");
//            getallnote(currentIndex,pageSize);
//        }
//        else if(thisid=="resType"){
//            $.cookie("puluIndexType",4);
//            $("#PuluTitleType").attr("class","resType");
//            getallnote(currentIndex,pageSize);
//        }
//    }
//});
/*
 筛选类型重新加载
 */
$("#choicetype").click(function(){
    $("#typelist").toggle();
    $(".toparr").toggle();
    $(".select").hide();
});
$("#typelist li.typelist").click(function(i){
    //取消冒泡
    var e=arguments.callee.caller.arguments[0]||event;
    if (e && e.stopPropagation) {
        e.stopPropagation();
    } else if (window.event) {
        window.event.cancelBubble = true;
    }
    if(readyover==0){
        var thisid=i.target.id.replace(/[0-9]/,"");
        $("#typelist li").attr("class","typelist");
        $("#"+thisid).attr("class","typelist active");
        $("#typelist").hide();
        $(".toparr").hide();
        //数据还原
        $("#waiting1").css("display","block");
        $("#nonews1").css("display","none");
        $("#nonews").css("display","none");
        pageSize=10;
        currentIndex=1;
        //页面重新加载
        $(window).scrollTop(0);
        $("#mainbody div.addlistplace div").remove();//清空页面
        switch(thisid){
            case "sjType":
                $.cookie("pulutype",1);
                $("#labeltypename i").attr("class","sjType");
                getallnote(currentIndex,pageSize);
                break;
            case "fjType":
                $.cookie("pulutype",3);
                $("#labeltypename i").attr("class","fjType");
                mapftn();
                break;
            case "llType":
                $.cookie("pulutype",2);
                $("#labeltypename i").attr("class","llType");
                getallnote(currentIndex,pageSize);
                break;
            case "zfType":
                $.cookie("pulutype",4);
                $("#labeltypename i").attr("class","zfType");
                getallnote(currentIndex,pageSize);
                break;
        }
    }
});

$().ready(function(){
    if($.cookie("MYNICK")){$("#threeFriendMy").html($.cookie("MYNICK"))}
    if(is_weixn()){
        if(/https/.test(location.href)){
            location.href="http://www.pulu.com/weixin/pulu.html";
        }
        if($.cookie("MYID")){ //$.cookie("wxopenid")
            loadpage();
        }
    }
    else{
        if(!$.cookie("MYID")){
            if(localStorage.getItem("MYID")){
                $.cookie("MYID",localStorage.getItem("MYID"));
                location.href="https://www.pulu.com/weixin/pulu.html";
                loadpage();
            }else{
                if((location.href)!="http://www.pulu.com/weixin/pulu.html"){
                    location.href="http://www.pulu.com/weixin/pulu.html";
                }else{
                    location.href="http://www.pulu.com/weixin/login.html";
                }
            }
        }
        else{
            if(!/https/.test(location.href)){
                console.log("no https");
                location.href="https://www.pulu.com/weixin/pulu.html";
            }else{
                if(location.href=="https://www.pulu.com"||location.href=="https://www.pulu.com/"){
                    location.href="https://www.pulu.com/weixin/pulu.html";
                }
                else{console.log(location.href)}
            }
            loadpage();
        }
    }
});
/**/
//setTimeout(function(){
//    $("#sendbtn .select").slideDown(1000);
//    if(!closeTimeOut){
//        slideUp();
//    }
//    else{clearTimeout();}
//},5000);
//function slideUp(){
//    setTimeout(function(){
//        $("#sendbtn .select").slideUp(1000);
//        clearTimeout();
//    },5000);
//}